<template>
	<view class="Jy_seckill_shop_page">
		<view class="Jy_group_barg_box" :style="{'padding-top' : statusBarHeight + 'px'}">
			<view class="left-back-box" @click="getBack()">
				<u-icon name="arrow-left" color="#ffffff" size="26"></u-icon>
			</view>
			<view class="right-title-box">
				<text>限时秒杀</text>
			</view>
		</view>
		<view class="Jy_group_skill-center-group">
			<scroll-view scroll-y="true" :style="{'height' : 'calc( 100vh - ' + statusBarHeight + 'px - 78rpx)'}">
				<view class="Jy_group_skill-center-box">
					<view class="bg_image">
						<!-- <swiper-item >
							<image :src="items.sattDir"  lazy-load></image>
						</swiper-item> -->
						<image src="https://f0.0sm.com/node0/2023/03/8640D5B0E7105D54-483a821159abe09e.png" mode="widthFix"></image>
					</view>

					<!-- 秒杀活动为空显示空状态 -->
					<view class="">
						<view class="">
							<view class="">

							</view>
							<view class="">
								<text></text>
							</view>
						</view>
					</view>
					<view class="Jy_group_skill-shop-list" v-for="(item, index) in seckillList" :key="index" @click="goSeckill(item)">
						<view class="Jy_content_main_shop_container">
							<view class="left-image-box">
								<image :src="item.image" mode="aspectFill"></image>
							</view>
							<view class="right_content_group">
								<view class="shop_name_box">
									<text>{{item.title}}</text>
								</view>
								<view class="shop_down-time-box">
									<view class="old_price-box">
										<text>限时限量, 抢完为止</text>
									</view>
								</view>
								<view class="bar-button-group">
									<view class="news-price-box">
										<view class="new-price">
											<text class="symbal">￥</text>
											<text class="size">{{item.price}}</text>
										</view>
									</view>
									<view class="button-group">
										<view class="kj-button-group">
											<view class="kj-button-box">
												<text>立即秒杀</text>
											</view>
										</view>
									</view>
								</view>
							</view>
						</view>
					</view>
					<view class="not_moore_active_box">
						<text>没有更多活动了~</text>
					</view>
				</view>
			</scroll-view>
		</view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				// 适配头部导航高度 
				statusBarHeight: getApp().globalData.statusBarHeight,
				circular: true,
				autoplay: true,
				interval: 500,
				topImage: '',
				seckillList: [],
				timeList: [],
				active: 0,
				scrollLeft: 0,
				interval: 0,
				status: 1,
				countDownHour: "00",
				countDownMinute: "00",
				countDownSecond: "00",
				page: 1,
				limit: 4,
				loading: false,
				loadend: false,
				pageloading: false,
				dataList: [],
				returnShow: true,
				navH: ''
			};
		},
		onLoad(option) {
			this.getHeader()
		},
		methods: {
			// 返回上一页
			getBack() {
				uni.navigateBack()
			},
			
			goSeckill(item){
				uni.navigateTo({
					url:'../../../../pages/shoppingDetail/shoppingSecckillDetail?seckillId='+item.id
				})
			},

			getHeader() {
				let that = this
				this.sendRequest({
					url: "/api/front/seckill/header",
					success: res => {
						res.data.data.map(item => {
							item.slide = JSON.parse(item.slide)
						})
						that.dataList = res.data.data;
						that.getSeckillList();
						that.seckillList = [];
						that.page = 1;
						that.status = that.dataList[that.active].status;
						that.getSeckillList();
					}
				})

			},
			// 获取商品列表
			getSeckillList() {
				var that = this;
				var data = {
					page: that.page,
					limit: that.limit
				};
				if (that.loadend) return;
				if (that.pageloading) return;
				this.pageloading = true
				// getSeckillList(that.dataList[that.active].id, data).then(res => {
				// 	var seckillList = res.data.list;
				// 	var loadend = seckillList.length < that.limit;
				// 	that.page++;
				// 	that.seckillList = that.seckillList.concat(seckillList),
				// 		that.page = that.page;
				// 	that.pageloading = false;
				// 	that.loadend = loadend;
				// }).catch(err => {
				// 	that.pageloading = false
				// });
				
				this.sendRequest({
					url: "/api/front/seckill/list/"+that.dataList[that.active].id,
					data: data,
					success: res => {
						var seckillList = res.data.data.list;
						var loadend = seckillList.length < that.limit;
						that.page++;
						that.seckillList = that.seckillList.concat(seckillList),
							that.page = that.page;
						that.pageloading = false;
						that.loadend = loadend;
					}
				})
			}
		}
	}
</script>

<style lang="scss" scoped>
	@import 'seckillVenue.scss';
</style>
